<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
	return View('home.person.index');
});

Route::namespace('Admin')->group(function () {
	Route::prefix('admin')->group(function () {
		//登录
		Route::get('Login', 'LoginController@Login');
		Route::get('doLogin', 'LoginController@doLogin');

		Route::middleware(['check.user'])->group(function () {
			//退出登录
			Route::get('LogOut', 'LoginController@LogOut');
			//商品类型
			Route::resource('CommodityType', 'CommodityTypeController', ['except' => [
				'edit', 'create'
			]]);
			//品牌
			Route::resource('Brand', 'BrandController', ['except' => [
				'edit', 'create'
			]]);
			//管理员
			Route::resource('Users', 'UsersController', ['except' => [
				 'create'
			]]);
			//角色
			Route::resource('Roles', 'RolesController', ['except' => [
				'create'
			]]);
			//权限
			Route::resource('Permissions', 'PermissionController', ['only' => [
				'index'
			]]);
			//会员
			Route::resource('Member', 'MemberController');
		});
	});
});


Route::namespace('Home')->group(function () {
	Route::get('judgeCaptcha', 'LoginController@judgeCaptcha');
	Route::get('ajaxRequestCheckIsExistsMember', 'LoginController@ajaxRequestCheckIsExistsMember');
	//注册页面
	Route::get('register', 'RegisterController@register');
	//处理邮箱注册
	Route::post('doEmailRegister', 'RegisterController@doEmailRegister');
	//用于获取当前用户是否存在
	Route::get('MemberisExists', 'RegisterController@isExists');
	//登录页面
	Route::get('Login', 'LoginController@login');
	//处理登录
	Route::post('doLogin', 'LoginController@doLogin');

	//验证用户登录的Middleware
	// Route::middleware(['MemberLogin'])->group(function () {
	// 	//
	// )};

});

//发送邮件
Route::get('mail', 'TextContoller@mail');

//验证码
Route::get('Captch', 'Common\Captch@showCaptch');
